package com.jyx.collection.array;

import java.awt.Button;
import java.awt.Checkbox;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.List;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 
 * author 		jyx
 * email 		jyxsuper@163.com
 * description: Sort
 * Company: 	myzczk
 * datetime: 	2017年9月4日 下午3:25:14
 */
public class Sort {

	public static void main(String[] args) {
		int[] arr = new int[]{1,31,21,33,44,62,26};
		selected(arr);
		System.out.println();
		maoPao(arr);
	}
	
	public static void selected(int[] arr){
		int index, value, temp;
		for (int i = 0; i < arr.length; i++) {
			index = i;
			value = arr[i];
			for (int j = i; j < arr.length; j++) {
				if(arr[j] < value){
					index = j;
					value = arr[j];
				}
			}
			temp = arr[i];
			arr[i] = arr[index];
			arr[index] = temp;
		}
		for (int i : arr) {
			System.out.print(i+" ");
		}
	}
	
	
	public static void maoPao(int arr[]){
		for (int i = 0; i < arr.length; i++) {
			for (int j = i; j < arr.length; j++) {
				if(arr[j] < arr[i]){
					int temp = arr[i];
					arr[i] = arr[j];
					arr[j] = temp;
				}
			}
		}
		for (int i : arr) {
			System.out.print(i+" ");
		}
	}

}